var sellerId = 1,
	selId, serveId = 1;

function Advice($scope, $http) {
	var url = getUrl("36findMarket");
	var headerJson = getHeader();
	var uid = readData(localStorage.account);
	var marketdata = "id=" + uid + "&seller=" + 1;
	//默认列表内容
	$http({
			method: 'POST',
			url: url,
			headers: headerJson,
			timeout: 10000,
			//cache: true,
			data: marketdata
		}).success(function(data, status, headers, config) {
			if (data.code == "0") {
				$scope.lists = data.obj.sellerlist;
				selId = data.obj.sellerlist[0].id;
			} else {}
		})
		//获得对于服务的选择id
	$scope.changeserve = function(num) {
			serveId = num
		}
		//控制下拉列表内容
	$scope.changelist = function(num) {
		//0,1,2 0商场 1商家 2 平台
		sellerId = num;
		var dataseller = "id=" + uid + "&seller=" + num;
		$http({
			method: 'POST',
			url: url,
			headers: headerJson,
			timeout: 10000,
			//cache: true,
			data: dataseller
		}).success(function(data, status, headers, config) {
			/*datas = {
			 "obj" : {
			 "sellerlist" : [{
			 "name" : "新龙商场",
			 "id" : "1233"
			 }, {
			 "name" : "花心商场",
			 "id" : "1243"
			 }, {
			 "name" : "新龙商场",
			 "id" : "1233"
			 }]
			 },
			 "code" : "0",
			 "msg" : "success"
			 };*/
			if (data.code == "0") {
				$scope.lists = data.obj.sellerlist;
				selId = data.obj.sellerlist[0].id;
			} else {
				$scope.lists = [];
			}
		})
	}
	$scope.sub = function() {
		if (!$scope.texare | !$scope.name | !$scope.way) {

			mui.toast("请完善信息后提交");
			return;
		}
		var url = getUrl("55advice");
		var headerJson = getHeader();
		paramdata = "accountId=" + readData(localStorage.account) + "&content=" + $scope.texare + "&name=" + $scope.name + "&phone=" + $scope.way + "&feedObj=" + sellerId + "&feedObjId=" + selId + "&feedType=" + serveId;
		//test = JSON.stringify(paramdata);
		//
		$http({
			method: 'POST',
			url: url,
			headers: headerJson,
			timeout: 10000,
			//cache: true,
			data: paramdata
		}).success(function(data, status, headers, config) {
			if (data.code == "0") {
				mui.toast("提交成功");
				setTimeout(function() {
					mui.back();
				}, 2000)
			}
			con.value = "";
		}).error(function(data, status, headers, config) {
			mui.toast("网络链接异常，请稍后重试");
		});
	}
}

function changeselect(s) {
	selId = s;
}
var con = document.getElementById("yijian");
$(document).ready(function() {
	$("#seller img").click(function() {
		$("#seller img").attr("src", "../../image/my/yj0.png");
		$(this).attr("src", "../../image/my/yj1.png");
	});
	$("#serve img").click(function() {
		$("#serve img").attr("src", "../../image/my/yj0.png");
		$(this).attr("src", "../../image/my/yj1.png");
	});
});